//
//  main.c
//  C_Study
//
//  Created by rui on 12-6-30.
//  Copyright (c) 2012年 Wang Rui. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

const int ExperimentsConut = 10000000;
int a[3] = {1,2,3}; //假设一代表有奖
int winCountIfChange = 0;
int winCountIfDontChange = 0;

int xiaoMingChose(){
	return a[rand()%3];	
}

int afterBossChoseLeftNumber(int numberXiaominChosen){
	if (numberXiaominChosen == 1) {
		return a[rand()%2+1];
	}
	else{
		return 1;
	}
}

void change(int numberInXiaominHand){
	if (numberInXiaominHand == 1) {
		winCountIfChange++;
	}
}

void dontChange(int numberInXiaominHand){
	if (numberInXiaominHand == 1) {
		winCountIfDontChange++;
	}
}


int main(int argc, const char * argv[])
{	
	
	srand((unsigned)time(NULL));
	
	
	int numberXiaominChosen = 0;
	int leftNumber = 0;
	
	for (int i=0; i<ExperimentsConut; i++) {
		numberXiaominChosen = xiaoMingChose();
		leftNumber = afterBossChoseLeftNumber(numberXiaominChosen);
		
		change(leftNumber);
		dontChange(numberXiaominChosen);
	}
	
	
	printf("change win count:%d \n",winCountIfChange);
	printf("dont change win count:%d\n",winCountIfDontChange);
	
	return 0;
}

